# 用程序模拟浏览器，输入一个网址，获取内容
from urllib.request import urlopen

url = "http://www.baidu.com"
resp = urlopen(url)

# 读取网页源代码
body = resp.read().decode("utf-8")
# print(body)

# 写入文件
with open("spider-target\\baidu.html", mode="w", encoding='utf-8') as f:
    f.write(body)

print("写入成功！over!")
